package com.songcha.library_common.util

import java.util.regex.Matcher
import java.util.regex.Pattern


class RegexUtil {
    companion object{
        @JvmStatic
        fun isPhone(phone:String):Boolean{
            val p: Pattern = Pattern.compile("^(1[3-9])\\d{9}$")
            val m: Matcher = p.matcher(phone)
            return (m.matches())
        }

        @JvmStatic
        fun isCardNumber(cardNumber:String):Boolean{
            val c_reg = "^(([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z](([0-9]{5}[ADF])|([ADF]([A-HJ-NP-Z0-9])[0-9]{4})))|([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z][A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳使领]))$"
            val p: Pattern = Pattern.compile(c_reg)
            val m: Matcher = p.matcher(cardNumber)
            return (m.matches())
        }

        @JvmStatic
        fun isChineseString(str:String):Boolean{
            if(str.isBlank()) return false
            val str2 = str.trim()
            for(i in str2.indices){
                if(!str2.get(i).toString().matches("[\u4E00-\u9FA5]".toRegex()))
                    return false
            }
            return true
        }

    }
}